package tds.model19.version2;
/**
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName GameRole
 * @Description 游戏角色
 * @author tds
 * @Date 2020/2/4 17:56
 * @version 1.0.0
 */
public class GameRole {
    /**
     * 生命
     */
    private int vit;

    /**
     * 攻击力
     */
    private int atk;

    /**
     * 防御力
     */
    private int def;

    public GameRole(int vit, int atk, int def) {
        this.vit = vit;
        this.atk = atk;
        this.def = def;
    }

    public void fight(){
        this.vit = 0;
    }

    @Override
    public String toString() {
        return "GameRole{" +
                "vit=" + vit +
                ", atk=" + atk +
                ", def=" + def +
                '}';
    }

    /**
     * @Description 创建游戏角色备份
     * @param
     * @return tds.model19.version2.RoleStateMemento
     */
    public RoleStateMemento createMemento(){
        return new RoleStateMemento(this.vit, this.atk, this.def);
    }

    /**
     * @Description 恢复存档点
     * @param roleStateMemento
     * @return void
     */
    public void recover(RoleStateMemento roleStateMemento){
        this.vit = roleStateMemento.getVit();
        this.atk = roleStateMemento.getAtk();
        this.def = roleStateMemento.getDef();
    }
}
